package psn.zjk.springboot.controller;

import java.util.Map;
import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.context.request.RequestContextHolder;

/** 普通控制层，返回页面 张骏凯 2020年1月31日 */
@Controller public class LoginController {

    private final Logger LOGGER = LoggerFactory.getLogger(getClass());

    @PostMapping("/login") public String hello(@RequestParam("username") String username,
            @RequestParam("password") String password, HttpServletRequest request, Map<String, Object> out) {
        if ("".equals(username) && "".equals(password)) {
            request.getSession().setAttribute("currentUser", username);
            return "redirect:dashboard";
        } else {
            out.put("msg", "code1");
            return "login";
        }
    }

}
